#!/bin/dash
{
	#////////////////////////////////////
	# DietPi PreBoot Script
	#
	#////////////////////////////////////
	# Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com
	#
	#////////////////////////////////////
	#
	# Info:
	# - Location: /boot/dietpi/preboot
	# - Activates on boot from dietpi-preboot.service, runs before dietpi-boot.service and networking
	#////////////////////////////////////

	#/////////////////////////////////////////////////////////////////////////////////////
	# Main Loop
	#/////////////////////////////////////////////////////////////////////////////////////
	#-----------------------------------------------------------------------------------
	# RPi: Disable display ports in headless mode to reduce power consumption by ~0.1W even without attached display, disabled hotplug detection and no framebuffer
	[ ! -f '/etc/.dietpi_hw_model_identifier' ] && grep -q '^[[:blank:]]*AUTO_SETUP_HEADLESS=1' /boot/dietpi.txt && tvservice -o

	# Obtain hardware info: Do on every boot since some contained info can change, especially when allowing RPi SDcard swap
	/boot/dietpi/func/dietpi-obtain_hw_model

	# Apply CPU governor and settings
	/boot/dietpi/func/dietpi-set_cpu
	#-----------------------------------------------------------------------------------
	exit
	#-----------------------------------------------------------------------------------
}
